<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>家庭医生信息管理系统</title>
    <#--<link rel="stylesheet" type="text/css" href="/easyui/1.5/themes/default/easyui.css" />-->
    <#--<link rel="stylesheet" type="text/css" href="/easyui/1.5/themes/icon.css" />-->
    <#--<link rel="stylesheet" type="text/css" href="/css/public.css">-->
    <link rel="stylesheet" href="/css/register.css">
    <link rel="icon" type="image/x-icon" href="/images/logo.png">
</head>
<body>
<div class="wrap">
    <div class="register-box">
        <div class="logo"></div>
        <p class="supplier-name">家庭医生信息管理系统</p>
        <div class="form-box">
            <div class="form">
                <ul class="register-list">
                    <li class="register-item">
                        <input type="text" id="username" name="userName" class="username-input" placeholder="用户名">
                    </li>
                    <li class="register-item">
                        <input type="text" id="password" name="password" class="password-input" placeholder="登录密码">
                    </li>
                    <li class="register-item">
                        <input type="text" id="nickname" name="nickname" class="telephone-input" placeholder="昵称">
                    </li>
                    <li class="register-item">
                        <input type="text" id="email" name="email" class="confirm-input" placeholder="邮箱">
                    </li>
                    <li class="register-item">
                        <input type="tel" id="phone" name="phone" class="telephone-input" placeholder="手机号码">
                    </li>
                    <li class="register-item">
                        <a id="submit" class="register-btn">注册</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>


<script src="/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/layer/layer.js"></script>
<script type="text/javascript" src="/easyui/1.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/easyui/1.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
    document.onkeydown=function(){
        if (event.keyCode == 13){
            $("#submit").click();
        }
    }

    $(function () {
        var oWrap = document.querySelector(".wrap");
        var oHeight = document.documentElement.clientHeight;
        var oWidth = document.documentElement.clientWidth;
        oWrap.style.height = oHeight + "px";
        oWrap.style.width = oWidth + "px";

        //校验手机号码
        jQuery.extend({
            checkmobileNo: function (str) {
                var re = /^1[3|7|5|8]\d{9}$/;
                if (re.test(str)) {
                    return true;
                } else {
                    return false;
                }
            }
        });

        //按钮提交
        $("#submit").click(function () {
            var username = $("#username").val();
            if (username=='') {
                com.msg_error("请输入用户名");
                return false;
            }
            var password = $("#password").val();
            if (password=='') {
                com.msg_error("请输入密码");
                return false;
            }

            var nickname = $("#nickname").val();
            if (nickname=='') {
                com.msg_error("请输入昵称");
                return false;
            }

            var email = $("#email").val();
            if (email=='') {
                com.msg_error("请输入邮箱");
                return false;
            }

            var phone = $("#phone").val();
            if (!$.checkmobileNo(phone)) {
                com.msg_error("手机号无效");
                return false;
            }

            var index = com.msg_load();
            $.ajax({
                type: "POST",
                url: "/user/save",
                data: {username:username,password:password,phone:phone,nickname:nickname,email:email},
                success: function (data) {
                    com.msg_load_close(index);
                    var d = eval(data);
                    if (data != null && d.msg == 'success') {
                        com.msg_success("注册成功，正在跳转登录界面");
                        setTimeout('location.href="/login"', 2000);
                    } else {
                        $("#checkCode").click();
                        com.msg_error(d.msg);
                    }
                }
            });
        });
    })
</script>
